/*
* Vec3Cache.java
* Copyright (C) 2003
*
* $Id: Vec3Cache.java,v 1.1 2005/01/16 15:16:44 cawe Exp $
*/
using System;
namespace Suake2.UI.util
{
	
	/// <summary> Vec3Cache contains float[3] for temporary usage.
	/// The usage can reduce the garbage at runtime.
	/// 
	/// </summary>
	/// <author>  cwei
	/// </author>
	public sealed class Vec3Cache
	{
		
		//private static Stack cache = new Stack();
		//UPGRADE_NOTE: Final was removed from the declaration of 'cache '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
		private static readonly float[][] cache = new float[64][];
		private static int index = 0;
		private static int max = 0;
		
		public static float[] get_Renamed()
		{
			//max = Math.max(index, max);
			return cache[index++];
		}
		
		public static void  release()
		{
			index--;
		}
		
		public static void  release(int count)
		{
			index -= count;
		}
		
		public static void  debug()
		{
			System.Console.Error.WriteLine("Vec3Cache: max. " + (max + 1) + " vectors used.");
		}
		static Vec3Cache()
		{
			for (int i = 0; i < 64; i++)
			{
				cache[i] = new float[3];
			}
		}
	}
}